﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using MvcEngine.Mvc.Models.ViewModels;
using MvcEngine.Core;

namespace MvcEngine.Mvc.Filters
{
    public class AntiForgeryActionFilter : IActionFilter
    {
        #region IActionFilter Members

        public void OnActionExecuted(ActionExecutedContext filterContext)
        {
            MvcEngineModel model = filterContext.Controller.ViewData.Model as MvcEngineModel;

            if (model != null)
            {
                model.AntiForgeryToken = new AntiForgeryToken(SiteContext.Current.Site.Id.ToString());
            }
        }

        public void OnActionExecuting(ActionExecutingContext filterContext)
        {

        }

        #endregion
    }
}
